﻿namespace PrimeNumber
{
    /// <summary>
    /// 输入一个数，计算不大于它的最大质数
    /// </summary>
    internal class Program
    {
        static void Main(string[] args)
        {
            DateTime start = DateTime.Now;
            int max = 0;
            int n = 0;
            n = Convert.ToInt32(Console.ReadLine());
            for (int m = 2; m < n; m++)
            {
                for (int i = 2; i <= m; i++)
                {
                    if (m % i == 0)
                    {
                        if (i == m)
                            max = m;
                        break;
                    }
                }
            }
            DateTime end = DateTime.Now;
            TimeSpan timeSpan = end - start;
            Console.WriteLine($"{n}以内的最大质数为{max}");
            Console.WriteLine($"计算时间为：{timeSpan.TotalSeconds}秒");
        }
    }
}